    /* 
        此模块是用户中心_用户管理_菜单维护
        crteae by xyr on 2017/09/12
    */

    <template>
        <div class="app-container">
            <div class="wrapper metadata">
                <!-- 功能树菜单.start -->
                <el-col :span="6" class="warp-main">
                    <div class="el-bar">
                        <p>
                            <i class="iconfont icon-users"></i>元数据目录树</p>
                        <!-- 
                                    :data 树数据
                                    :node-key 每个树节点用来作为唯一标识的属性，整颗树应该是唯一的
                                    :default-expanded-keys="[2, 3]" 默认展开的节点的 key 的数组
                                    :default-checked-keys="[5]" 默认勾选的节点的 key 的数组
                                    :props="props" 参数列表
                                    @check-change 节点选中状态发生变化时的回调
                                    @node-click 节点被点击时的回调
                                    :load 加载子树数据的方法
                            -->
                        <el-tree ref="functionTree" 
                                :data="regions" 
                                :props="props" 
                                :load="loadNode" 
                                node-key="id" 
                                lazy  
                                @node-click="handleNodeClick" default-expand-all >
                                <span class="custom-tree-node" slot-scope="{ node, data }">
                                    <span>
                                        <i class="el-icon-upload"></i>{{ node.label }}
                                    </span>              
                                </span>
                        </el-tree>
                    </div>
                </el-col>
                <!-- 功能树菜单.end -->

                <!-- 功能信息.start -->
                <el-col :span="18" class="warp-main" style="padding-left:30px;">
                    <el-tabs class="el-bar" v-model="activeName">
                        <el-tab-pane label="基本信息" name="first">
                            <el-form ref="functionForm" :model="functionForm" autoComplete="on" :rules="functionRules" label-width="90px">                    
                                <el-form-item label="树节点类型" prop="type">
                                    <el-radio-group v-model="functionForm.type">
                                    <el-radio label="0">目录</el-radio>
                                    <el-radio label="1">索引</el-radio>
                                    <el-radio label="2">表名</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <el-form-item label="树节点名称" prop="name">
                                    <el-input v-model="functionForm.name" autoComplete="on" placeholder="元数据名称" style="width:99%;"></el-input>
                                </el-form-item>
                                <el-form-item label="上级菜单" >
                                    <el-input v-model="parentNodeName" :disabled="true" placeholder="如果是根目录,此处为空" style="width:99%;"></el-input>
                                </el-form-item>
                                <el-form-item label="创建时间" >
                                    <el-input v-model="functionForm.createTime" :disabled="true" placeholder="如果是根目录,此处为空" style="width:99%;"></el-input>
                                </el-form-item>
                                <el-form-item label="最后更新时间" >
                                    <el-input v-model="functionForm.lastUpdateTime" :disabled="true" placeholder="如果是根目录,此处为空" style="width:99%;"></el-input>
                                </el-form-item>
                                <div class="form-btn" style="padding-right:10px">
                                    <el-form-item >
                                        <el-button type="primary" class="iconfont icon-xinzeng" @click="addFunction">新增</el-button>
                                        <el-button type="success" class="iconfont icon-baocun" @click="saveFunction">保存</el-button>
                                        <el-button type="danger" icon="el-icon-delete" :disabled="disableFunctionDeleteButton" @click="deleteFunction">删除</el-button>
                                    </el-form-item>
                                </div>
                            </el-form>
                        </el-tab-pane>
                        <el-tab-pane label="元数据管理" name="second">
                        <el-table @expand-change="expandChange" :data="metadatas" highlight-current-row show-summary>
                            <el-table-column type="expand" width="50">
                                <template slot-scope="scope">
                                    <pre style="text-align:left;word-wrap: break-word; white-space: pre-wrap;width:800px">
                                            {{metadataDetailsJson}}
                                    </pre>
                                </template>
                            </el-table-column>
                            <el-table-column align="left" prop="opration" label="状态" width="60">
                                <template slot-scope="scope">
                                    <el-tooltip class="item" effect="light" placement="top-start">
                                        <div slot="content" v-if="scope.row.status === 'SUCCESS'">上次导入数据成功</div>
                                        <div slot="content" v-else-if="scope.row.status === 'FAILURE'">上次导入数据未完成</div>
                                        <div slot="content" v-else-if="scope.row.status === 'NOT_BUILT'">未导入数据</div>
                                        <div slot="content" v-else-if="scope.row.status === 'BUILDING'">导入数据中...</div>
                                        <i class='el-icon-loading' style="color: rgb(0, 0, 255); font-size: 20px;" v-if="scope.row.status === 'BUILDING'"></i>
                                        <i class='el-icon-success' style="color: rgb(0, 0, 255); font-size: 20px;" v-if="scope.row.status === 'SUCCESS'"></i>
                                        <i class='el-icon-error' style="color: rgb(255, 0, 0); font-size: 20px;" v-else-if="scope.row.status === 'FAILURE'"></i>
                                        <i class='el-icon-info' style="color: rgb(96, 96, 96); font-size: 22px;" v-else-if="scope.row.status === 'NOT_BUILT'"></i>
                                    </el-tooltip>
                                </template>
                                </el-table-column>
                            <el-table-column align="left" prop="index" label="索引" width="120">
                            </el-table-column>
                            <el-table-column align="left" prop="type" label="表名" width="120">
                            </el-table-column>
                            <el-table-column align="left" prop="count" label="数据总量" width="80">
                            </el-table-column>
                            <el-table-column prop="createTime" label="创建时间" width="155">
                            </el-table-column>
                            <el-table-column prop="lastUpdateTime" label="最后时间" width="155">
                            </el-table-column>
                            <el-table-column label="操作" fixed="right" width="140">
                                    <template slot-scope="scope">
                                        <el-tooltip content="属性信息维护" placement="top">
                                            <el-button style="padding: 6px 10px !important;" @click="metadataPropHadle(scope.row)" circle icon="el-icon-edit-outline" type="primary" size="mini"></el-button>
                                        </el-tooltip>
                                        <el-tooltip content="文件导入数据" placement="left">
                                            <el-upload ref="uploadFile" 
                                                :action="uploadAction" 
                                                :headers="uploadHeaders" 
                                                :multiple="false" 
                                                :auto-upload="true" 
                                                :show-file-list="false" 
                                                :limit="1" 
                                                :on-success="handleAvatarSuccess" 
                                                :on-error="handleAvatarError" 
                                                :before-upload="beforeAvatarUpload" 
                                                :on-exceed="handleExceed" style="display:inline-block;">
                                                <el-button style="padding: 6px 10px !important;" @click="handleUpLoadBtnClick(scope.row)" icon="el-icon-upload" size="small" type="primary"></el-button>
                                            </el-upload>
                                        </el-tooltip>
                                        
                                        <el-tooltip content="服务列表" placement="top">
                                            <el-button style="padding: 6px 10px !important;" @click="metadataServiceVisible=true" circle icon="el-icon-document" type="primary" size="mini"></el-button>
                                        </el-tooltip>
                                        
                                    </template>
                                </el-table-column>
                        </el-table>

                    
                        </el-tab-pane>
                    </el-tabs>
                </el-col>
                <!-- 功能信息.end -->
                <!--新增/修改元数据字段信息-->
                <el-dialog ref="dialog" :title="metadataPropTitle" :visible.sync="metadataPropVisible" :close-on-click-modal="true" width="850px">
                        <el-form :inline="true" ref="f2" style="line-height: 5px;padding: 2px 2px">
                            <el-form-item label-width="40px" label="顺序"/>
                            <el-form-item label="属性名称" label-width="135px" />
                            <el-form-item style="margin-left:110px" label="属性字段" label-width="70px" />
                            <el-form-item style="margin-left:40px" label="字段类型" label-width="150px" />
                        </el-form>
                        <el-form :inline="true" ref="f3" style="line-height: 2px;padding: 1px 1px;" :model="metadataProp" class="form-top" v-for="(mp, index) in metadataProp.mps" :key="mp.key">
                            <el-form-item label-width="100px" style="margin:0px;margin-bottom: 5px !important" label="" :prop="'mps.' + index + '.value'">
                                <el-input style="width:50px;" disabled :value="index+1"></el-input>            
                            </el-form-item>
                            <el-form-item label-width="150px" style="margin:0px;margin-bottom: 5px !important">
                                <el-input style="width:180px;" v-model="mp.propName"></el-input>                        
                            </el-form-item>
                            <el-form-item label-width="150px" style="margin:0px;margin-bottom: 5px !important">
                                <el-input style="width:180px;" v-model="mp.propField"></el-input>          
                            </el-form-item>
                            <el-form-item label-width="150px" style="margin:0px;margin-bottom: 5px !important">
                               <el-select style="width:180px;margin-left:10px" v-model="mp.propFieldType" placeholder="字段类型">
                                    <el-option v-for="item in metadataPropType" :key="item.type" :label="item.name" :value="item.type">
                                    </el-option>
                              </el-select>                       
                            </el-form-item>
                            <el-form-item label-width="150px" style="margin:0px;margin-bottom: 5px !important">                               
                                <el-tooltip class="item" effect="dark" content="删除属性信息">
                                    <el-button type="danger" @click.prevent="removeMetadataProp(mp)">-</el-button>
                                </el-tooltip>                              
                            </el-form-item>
                        </el-form>
                        <div style="margin-left3px">
                            <el-tooltip class="item" effect="dark" content="增加属性信息">
                                <el-button type="primary" @click="addMetadataProp">+</el-button>
                            </el-tooltip>
                        </div>
                        <div slot="footer" class="dialog-footer">
                            <el-button class="iconfont icon-chehui" @click="metadataPropVisible=false">取消</el-button>
                            <el-button class="iconfont icon-fuxuan" @click="saveMetadataProp" type="primary">确定</el-button>
                        </div>
                </el-dialog>
                <!--服务列表-->
                <el-dialog ref="dialog2" title="元数据服务列表" :visible.sync="metadataServiceVisible" :close-on-click-modal="true" width="950px">
                        <el-table :data="metadataServices" highlight-current-row>    
                            <el-table-column type="expand" width="0">
                                <template slot-scope="scope">
                                     <el-table :data="scope.row.p" highlight-current-row>   
                                        <el-table-column label="请求参数:">
                                            <el-table-column align="left" width="200" prop="name" label="参数名称"></el-table-column>
                                            <el-table-column align="left" width="200" prop="type" label="参数类型"></el-table-column>  
                                            <el-table-column align="left" width="300" prop="desc" label="说明"></el-table-column>    
                                        </el-table-column>                                                              
                                     </el-table>
                                    <el-table :data="scope.row.response" highlight-current-row> 
                                        <el-table-column label="返回参数:">   
                                            <el-table-column align="left" width="200" prop="name" label="参数名称"></el-table-column>
                                            <el-table-column align="left" width="200" prop="type" label="参数类型"></el-table-column>  
                                            <el-table-column align="left" width="300" prop="desc" label="说明"></el-table-column> 
                                        </el-table-column>                            
                                     </el-table>
                                </template>
                            </el-table-column>                        
                            <el-table-column width="550" align="left" prop="api" label="服务列表"></el-table-column>
                            <el-table-column width="70"  align="left" prop="method" label="方法"></el-table-column>  
                            <el-table-column width="200" align="left" prop="desc" label="说明"></el-table-column>                         
                        </el-table>
                </el-dialog>
            </div>
        </div>
    </template>

    /* 
    数据处理
    */
    <script>


    export default {
        data() {
            // 表单校验
            // 功能名称校验
            const validateName = (rule, value, callback) => {
                if (value.length < 2) {
                    callback(new Error('树节点名称不能为空'));
                } else {
                    callback();
                }
            };

            // 所属功能的ID校验
            const validateBelongId = (rule, value, callback) => {
                if (value.length < 2) {
                    callback(new Error('请输入所属功能ID'))
                } else {
                    callback();
                }
            };

            return {
                activeName: 'first',
                //== 左边树菜单.start
                // 树菜单数据加载
                regions: [],
                // 数据菜单参数
                props: {
                    label: 'name',
                    children: 'zones'
                },
                count: 3,
                //== 左边树菜单.end

                //== 右边功能信息.start
                functionForm: {
                    id: '',
                    name: '',
                    belongName:'',
                    type: "0",
                    belongAllId:'',
                    belongId:'',
                    createTime:'',
                    lastUpdateTime:''
                },
                // checkList: ['是否菜单'],

                // 表单校验
                functionRules: {
                    name: [
                        { required: true, trigger: 'blur', validator: validateName }
                    ]
                },

                // 全局变量配置
                // 删除按钮禁用
                disableFunctionDeleteButton: true,
                // 是否新增功能菜单
                isAddFunction: true,
                // 是否修改功能菜单
                isUpdateFunction: false,
                // 当前选中功能菜单节点的ID
                selectNodeId: '',
                // 当前所选的节点的上级菜单
                parentNodeName: '',
                // 当前所选节点的名字
                selectNodeName: '',


                //== 右边功能信息.end

                //元数据管理.start
                metadatas: 
                [
                    // {
                    // index: 'index_1',
                    // type: 't_1',
                    // count: 1000000,
                    // createTime:'2019-06-15 17:00:24',
                    // lastUpdateTime:'2019-06-15 17:00:24'
                    //}
                ],
                metadataDetailsJson:'',
                metadataDetails:[],
                //元数据管理.end
                //元数据数据文件导入.start
                // 上传文件动作头部
                uploadHeaders: {
                    "X-Token": this.$store.getters.token
                },
                uploadId:'',
                uploadIndex:'',
                uploadType:'',
                //元数据数据文件导入.end
                //元数据属性维护.start
                metadataPropTitle: '元数据属性字段新增/修改',//
                metadataPropVisible: false,      //
                handleMetadataPropMetadataId:'',
                metadataProp:{
                    mps:[]                   
                },
                metadataPropType:[
                    {
                        type:'0',
                        name:'文本型'
                    },
                    {
                        type:'1',
                        name:'整型'
                    },{
                        type:'2',
                        name:'浮点型'
                    }
                ],
                //元数据属性维护.end
                //元数据服务列表.start
                metadataServiceVisible:false,                
                metadataServices:[
                    {
                        api:"http://metadata-admin.changengcloud.com:32100/api/{索引号}/{表名}/summary",
                        method:"Get",
                        desc:"数据概要",
                        p:[
                        ],
                        response:[
                            {
                                name:"code",
                                type:'int',
                                desc:'200:正常结果,其他:异常结果'
                            },{
                                name:"errorMsg",
                                type:'string',
                                desc:'异常结果时的异常信息'
                            },{
                                name:"result",
                                type:'Map',
                                desc:'概要内容'
                            }
                        ]
                    }
                    ,{
                        api:"http://metadata-admin.changengcloud.com:32100/api/{索引号}/{表名}/count",
                        method:"Get",
                        desc:"统计总数",
                        p:[
                        ],
                        response:[
                            {
                                name:"code",
                                type:'int',
                                desc:'200:正常结果,其他:异常结果'
                            },{
                                name:"errorMsg",
                                type:'string',
                                desc:'异常结果时的异常信息'
                            },{
                                name:"result",
                                type:'long',
                                desc:'统计结果'
                            }
                        ]
                    },{
                        api:"http://metadata-admin.changengcloud.com:32100/api/{索引号}/{表名}/queryById",
                        method:"Get",
                        desc:"根据id获取数据",
                        p:[
                            {
                                name:"id",
                                type:'string',
                                desc:'id值'
                            }
                        ],
                        response:[
                            {
                                name:"code",
                                type:'int',
                                desc:'200:正常结果,其他:异常结果'
                            },{
                                name:"errorMsg",
                                type:'string',
                                desc:'异常结果时的异常信息'
                            },{
                                name:"result",
                                type:'Map',
                                desc:'结果Map对象'
                            }
                        ]
                    },{
                        api:"http://metadata-admin.changengcloud.com:32100/api/{索引号}/{表名}/deleteById",
                        method:"Delete",
                        desc:"根据id删除数据",
                        p:[
                            {
                                name:"id",
                                type:'string',
                                desc:'id值'
                            }
                        ],
                        response:[
                            {
                                name:"code",
                                type:'int',
                                desc:'200:正常结果,其他:异常结果'
                            },{
                                name:"errorMsg",
                                type:'string',
                                desc:'异常结果时的异常信息'
                            },{
                                name:"result",
                                type:'int',
                                desc:'影响结果的个数'
                            }
                        ]
                    },{
                        api:"http://metadata-admin.changengcloud.com:32100/api/{索引号}/{表名}/updateById",
                        method:"Put",
                        desc:"根据id修改数据",
                        p:[
                            {
                                name:"id",
                                type:'string',
                                desc:'id值'
                            },{
                                name:"data",
                                type:'string',
                                desc:'待修改字段map字符串'
                            }
                        ],
                        response:[
                            {
                                name:"code",
                                type:'int',
                                desc:'200:正常结果,其他:异常结果'
                            },{
                                name:"errorMsg",
                                type:'string',
                                desc:'异常结果时的异常信息'
                            },{
                                name:"result",
                                type:'int',
                                desc:'影响结果的个数'
                            }
                        ]
                    },{
                        api:"http://metadata-admin.changengcloud.com:32100/api/{索引号}/{表名}/queryByKey",
                        method:"Get",
                        desc:"根据关键字搜索数据",
                        p:[
                            {
                                name:"key",
                                type:'string',
                                desc:'关键字'
                            }
                        ],
                        response:[
                            {
                                name:"code",
                                type:'int',
                                desc:'200:正常结果,其他:异常结果'
                            },{
                                name:"errorMsg",
                                type:'string',
                                desc:'异常结果时的异常信息'
                            },{
                                name:"result",
                                type:'array',
                                desc:'结果数组'
                            }
                        ]
                    }
                ],    
                //元数据服务列表.end
            }; // end of return
        }, // end of data
        created() { // 页面加载时候,就初始化数据
            // this.loadNode(node, resolve);
        },
        methods: { // 方法集合
            expandChange(row,expandedRows){
                this.metadataDetailsJson='';
                if(!expandedRows==''){
                    //展开行时
                    let index=row.index;
                    let type=row.type;
                    let url=this.projectConfig.URL_API_METADATA_DETAIL+'?index='+index+'&type='+type;
                    this.httpClient.httpClientget(url, '').then(res => {
                    let _code = res.meta.code;
                    if (_code == this.projectConfig.CODE_OK) {
                         // 成功加载数据
                        this.metadataDetailsJson=res.data;
                        //console.log(this.metadataDetailsJson);
                    } else {
                        this.metadataDetailsJson='';
                    }
                 });    
                }
            },
            metadataPropHadle(row){
                this.handleMetadataPropMetadataId=row.id;
                //查询属性信息
                this.metadataProp.mps=[];
                let url=this.projectConfig.URL_API_METADATA_PROP+'/'+this.handleMetadataPropMetadataId;
                 this.httpClient.httpClientget(url, '').then(res => {
                     let _code = res.meta.code;
                    if (_code == this.projectConfig.CODE_OK) {
                         // 成功加载数据
                        this.metadataProp.mps=res.data;
                    } else {
                        this.metadataProp.mps=[];
                    }
                 });    
                this.metadataPropVisible = true;
            },
            removeMetadataProp(item) {
                if (this.metadataProp.mps.length == 1) {
                    this.$message({
                        message: '至少需要创建1个属性字段!',
                        type: 'warning'
                    });
                    return;
                }
                var index = this.metadataProp.mps.indexOf(item)
                if (index != -1) {
                    this.metadataProp.mps.splice(index, 1)
                }
            },
            addMetadataProp() {
                this.metadataProp.mps.push(
                    {
                            id: '',
                            metadataId: this.handleMetadataPropMetadataId,
                            propName:'',
                            propField: "",
                            propFieldType:'0',
                            propSort:0,
                            createTime:'',
                            lastUpdateTime:''
                    }
                );
            },
            // 保存元属性信息
            saveMetadataProp() {
               //验证逻辑
               let errorFlag = false;
               let _this=this;
               if(this.metadataProp.mps.length==0){
                   _this.$message({
                        message: '至少需要创建1个属性字段!',
                        type: 'warning'
                    });
                    return;
               }
               this.metadataProp.mps.forEach(function(item,index){
                   item.propSort=index+1;
                    if (item.propName == '') {
                        _this.$message({
                            message: '属性名称不能为空!',
                            type: 'warning'
                        });
                        errorFlag = true;
                        return;
                    };
                    if (item.propField == '') {
                        _this.$message({
                            message: '属性字段不能为空!',
                            type: 'warning'
                        });
                        errorFlag = true;
                        return;
                    };
               });
               if (!errorFlag) {
                   this.httpClient.httpClientPost(this.projectConfig.URL_API_METADATA_PROP,this.metadataProp).then(res => {
                        //处理成功
                        this.metadataPropVisible = false;
                   });
               }
            },
            // 树节点被点击时候的回调
            handleNodeClick(data,node,resolve) {
                // 得到当前节点的id
                let _id = data.id;
                // 获得当前节点的名字
                let _name = data.name;

                // 得到父菜单的data id
                let _parentId = node.parent.data.id;

                if (typeof _parentId == 'undefined') {
                    _parentId = '';
                }
                
                // 根据ID,获得当前节点的信息,并且赋值给右边表单
                if (typeof _id != 'undefined' && _id.length > 0) {
                    // 直接获得当前节点的data进行赋值,不需要再请求后台进行交互
                    this.functionForm.id = data.id;
                    this.functionForm.name = data.name;
                    this.functionForm.belongName = data.belongName;
                    
                    this.functionForm.type = data.type;
                    this.functionForm.belongId = data.belongId;
                    this.functionForm.belongAllId=data.belongAllId;
                    this.functionForm.createTime = data.createTime;
                    this.functionForm.lastUpdateTime=data.lastUpdateTime;
                    // 赋值到全局变量,
                    this.selectNodeId = data.id;
                    // 得到当前节点的上级菜单名字
                    let parentNodeNameTemp = node.parent.data.name;
                    if (typeof parentNodeNameTemp != 'undefined') {
                        this.parentNodeName = parentNodeNameTemp
                    } else {
                        this.parentNodeName = '';
                    }
                    // 赋值到全局当前所选节点的名字,在此节点增加节点的时候,用于显示
                    this.selectNodeName = data.name;
                    
                    
                    // 打开删除按钮,可以删除
                    this.disableFunctionDeleteButton = false;
                    // 可以修改
                    this.isAddFunction = false;
                    this.isUpdateFunction = true;

                    // 元数据统计信息获取
                    let statisUrl=this.projectConfig.URL_API_METADATA_STATIS+'/'+this.selectNodeId;
                    this.httpClient.httpClientget(statisUrl, '').then(res => {
                        let _code = res.meta.code;
                        if (_code == this.projectConfig.CODE_OK) {
                            // 成功加载数据
                            this.metadatas=res.data;
                        } else {
                            this.metadatas=[];
                        }
                    });
                }

            },
            // 加载树菜单的子节点
            loadNode(node, resolve) {
                // this.resolveTemp = resolve;
                if (node.level === 0) {
                    // 获得根节点
                    this.httpClient.httpClientget(this.projectConfig.URL_API_METADATA_GET_ROOT_NODE, '').then(res => {
                        let _code = res.meta.code;
                        if (_code == this.projectConfig.CODE_OK) {
                            // 成功加载数据
                            return resolve(res.data);
                        } else {
                            return resolve([]);
                        }
                    });
                } else {
                    // 加载子节点
                    let _id = node.data.id;
                    if (typeof _id != 'undefined') {
                        const params = [_id];
                        this.httpClient.getParamOnPath(this.projectConfig.URL_API_METADATA_GET_CHILDREN_NODE , params).then(res => {
                            if (res.meta.code == this.projectConfig.CODE_OK) {
                                // 成功加载数据
                                return resolve(res.data);
                            } else {
                                return resolve([]);
                            }
                        })
                    }
                };
            }, // loading end
            // 新增功能菜单
            addFunction() {
                // 清楚表单数据
                this.$refs.functionForm.resetFields();
                // 新增
                this.isAddFunction = true;
                this.isUpdateFunction = false;


                // 禁用删除按钮
                this.disableFunctionDeleteButton = true;

                // 将当前选中的功能菜单ID,赋值到右边的所属功能ID输入框中
                this.functionForm.belongId = this.selectNodeId;
                this.functionForm.belongName = this.selectNodeName;
                // 先当前节点名字,在此节点上增加菜单
                this.parentNodeName = this.selectNodeName;
                this.functionForm.createTime = '';
                this.functionForm.lastUpdateTime='';
            },
            // 保存功能菜单
            saveFunction() {
                // 表单校验
                this.$refs.functionForm.validate(valid => {
                    if (valid) {
                        // 新增功能菜单
                        if (this.isAddFunction) {
                            // 操作审计
                            //this.userBaseInfo.setOperObjectName(this.functionForm.name);
                            // 根据功能菜单名字和所属功能ID,判断同一级菜单下,是否存在相同功能菜单
                            this.httpClient.httpClientPost(this.projectConfig.URL_API_METADATA_ADD,this.functionForm).then(res => {
                                // 200 新增成功
                                // 601 数据重复
                                

                                // 进来就是200
                                // 清楚页面数据
                                this.addFunction();
                                // 刷新页面
                                this.refushTable();
                            });
                        }

                        // 修改功能菜单
                        if (this.isUpdateFunction) {
                            // 操作审计
                            //this.userBaseInfo.setOperObjectName(this.functionForm.name);
                            this.httpClient.httpClientPatch(this.projectConfig.URL_API_METADATA_UPDATE,this.functionForm).then(res => {
                                
                                this.refushTable();
                            });
                        }

                    } else {
                        return false;
                    }
                });
            },
            // 树菜单,重新加载
            reloadTree() {
                this.httpClient.httpClientget(this.projectConfig.URL_API_METADATA_GET_ROOT_NODE, '').then(res => {
                
                    this.regions = [];
                    this.regions = res.data;
                });
            },
            // 删除功能信息
            deleteFunction() {
                let functionId = this.functionForm.id;
                if (functionId.length == 0 && typeof functionId == 'undefined') {
                    this.$notify.info({
                        message: '请选择一条功能菜单信息'
                    });
                } else {
                    this.$confirm('此操作将永久删除该功能菜单, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        // 操作审计
                        //this.userBaseInfo.setOperObjectName(this.functionForm.name);
                        // let param = [ functionId ];
                        let deleteUrl = this.projectConfig.URL_API_METADATA_DELETE + '/' + functionId;
                        // 执行删除操作
                        this.httpClient.httpClientDelete(deleteUrl,'').then( res => {
                            let _msg = '删除菜单:' + this.functionForm.name + ',成功';
                            

                        })
                        
                        // 刷新页面
                        this.refushTable();
                        

                    }).catch(() => {
                            
                    });
                }
            },
            refushTable() {
                // 清除表单数据
                this.$refs.functionForm.resetFields();
                // 重载用户搜索数据
                this.isAddFunction = false;
                this.isUpdateFunction = false;
                // 单选按钮还原
                this.functionForm.isMenu = true;
                this.functionForm.active = false;
                // 禁用删除按钮
                this.disableFunctionDeleteButton = true;
                // 重新加载树
                this.reloadTree();
            },
            // 上传文件前
            beforeAvatarUpload(file) {
                //console.log(file);
                // 判断文件是否为空
                if (file != null || file != "") {
                    let fileName = file.name;
                    if (fileName.indexOf("txt") == -1) {
                    this.$notify.warning({
                        message: "请选择txt文件"
                    });
                    return false;
                    }
                }
                return true;
            },
            // 上传文件成功,回调
            handleAvatarSuccess(res, file) {
                this.$refs.uploadFile.clearFiles();
                let _msg = res.meta.message;
                if(_msg=='文件上传成功!'){
                    this.$notify.success(_msg);
                }else{
                    this.$notify.error(_msg);
                }
            },
            // 上传文件,失败
            handleAvatarError(err, file) {
                this.$notify.error("上传文件失败,请重新上传");
                this.$refs.uploadFile.clearFiles();
            },
            // 超出选择文件个数
            handleExceed(files, fileList) {
                this.$notify.warning("只能选择一个文件");
            },

            handleUpLoadBtnClick(row){
                this.uploadId=row.id;
                this.uploadIndex=row.index;
                this.uploadType=row.type;
                row.status='BUILDING';
            }
        },
        computed: {
            uploadAction(){
                let baseUrl=this.httpClient.getApiHostname();
                let url=baseUrl+this.projectConfig.URL_API_METADATA_IMPORT;
                url+="?id="+this.uploadId;
                url+="&index="+this.uploadIndex;
                url+="&type="+this.uploadType;
                //console.log(url);
                return url;
            }
        },
    };
    </script>

    /* 
        样式设置
    */
    <style>
    .metadata .el-bar p {
        margin: 0;
        padding: 0 10px;
        height: 30px;
        line-height: 30px;
        border-bottom: 1px solid #d1dbe5;
    }

    .metadata .el-tree {
        border: none;
    }

    .metadata .el-form {
        padding: 22px 20px;
    }

    .metadata .el-bar p i {
        color: #777;
        font-size: 15px;
        margin-right: 6px;
    }

    .metadata .yes {
        position: absolute;
        top: 0;
        left: 62%;
    }

    .metadata .form-btn {
        border-top: 1px solid #f0f0f0;
        padding-top: 20px;
        text-align: right;
    }

    .el-table th > .cell {
        text-align: left !important;
    }

    .page .el-table__expanded-cell .is-leaf, .el-table__expanded-cell .el-table__row td {
        padding-left: 10px !important;
        box-sizing: border-box !important;
    }

    </style>